home *** CD-ROM | disk | FTP | other *** search
- class pi.AudioLibrary
- {
- static var sounds = new Array();
- function AudioLibrary()
- {
- }
- static function reset()
- {
- for(var _loc1_ in pi.AudioLibrary.sounds)
- {
- pi.AudioLibrary.sounds[_loc1_].removeMovieClip();
- }
- pi.AudioLibrary.sounds = new Array();
- }
- static function addSound(soundName, timeline)
- {
- if(typeof pi.AudioLibrary.sounds[soundName] != "object")
- {
- timeline.createEmptyMovieClip(soundName + "_sound_mc",timeline.getNextHighestDepth());
- pi.AudioLibrary.sounds[soundName] = new Sound(timeline[soundName + "_sound_mc"]);
- pi.AudioLibrary.sounds[soundName].attachSound(soundName);
- }
- else
- {
- trace(soundName + " already exists");
- }
- }
- static function playSound(soundName, repeat)
- {
- if(repeat == -1)
- {
- pi.AudioLibrary.sounds[soundName].start(0,1);
- pi.AudioLibrary.sounds[soundName].onSoundComplete = function()
- {
- pi.AudioLibrary.sounds[soundName].start();
- };
- }
- else
- {
- pi.AudioLibrary.sounds[soundName].start(0,repeat);
- pi.AudioLibrary.sounds[soundName].onSoundComplete = function()
- {
- };
- }
- }
- static function playLoopWithIntro(introName, loopName)
- {
- pi.AudioLibrary.sounds[introName].start(0,1);
- pi.AudioLibrary.sounds[introName].onSoundComplete = function()
- {
- pi.AudioLibrary.sounds[loopName].start(0,99999);
- };
- }
- static function stopSound(soundName)
- {
- pi.AudioLibrary.sounds[soundName].stop();
- }
- static function setVolume(soundName, volume)
- {
- pi.AudioLibrary.sounds[soundName].setVolume(volume);
- }
- static function setGlobalVolume(volume)
- {
- var _loc1_ = undefined;
- for(_loc1_ in pi.AudioLibrary.sounds)
- {
- pi.AudioLibrary.sounds[_loc1_].setVolume(volume);
- }
- }
- static function setPan(soundName, position)
- {
- pi.AudioLibrary.sounds[soundName].setPan(position);
- }
- }
-